package com.jiangxjsy.crm.support;

import com.jiangxjsy.core.redis.Redis;
import com.jiangxjsy.core.system.SystemCore;
import com.jiangxjsy.model.core.entity.UserInfo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * wukong-crm-master
 * 蒋胜宇
 * 2025/6/19 15:17
 */

@Component
public class AdminUserSupport {
    @Resource
    private Redis redis;

    /**
     * 判断是否是管理员
     *
     * @param token 用户 token
     * @param userId 用户 id
     * @return true 是管理员
     */
    public boolean isAdmin(String token, Long userId) {
        UserInfo userInfo = redis.get(UserInfo.class, token);
        return SystemCore.getSuperUser().equals(userId) || userInfo.getRoles().contains(SystemCore.getSuperRole());
    }
}
